import { EventType } from '../event_type';
import {
  initUserInfo,
  getUserInfo,
  getUserRole,
  getUserArring,
  getUserEquip,
  getUserGoods,
  getUserShop,
  changeName,
} from './user';
import { roleUp, roleDown, roleChange, roleEquipChange } from './arraying';
import { recruitRole, upgradeRole } from './role';
import { goodsSell } from './goods';
import { vipCanGet, vipReward } from './vip';
import { shopBuy } from './shop';
import { bossBattle } from './battle';
import type { GameMsg } from '../types';

export const sv = (user_id: string, msg: GameMsg) => {
  const { id, data } = msg;

  switch (id) {
    case EventType.INIT_USER_INFO: {
      return initUserInfo(user_id);
    }
    case EventType.UPDATE_USER_INFO: {
      return getUserInfo(user_id);
    }
    case EventType.UPDATE_USER_ROLE: {
      return getUserRole(user_id);
    }
    case EventType.UPDATE_USER_ARRAYING: {
      return getUserArring(user_id);
    }
    case EventType.UPDATE_USER_EQUIP: {
      return getUserEquip(user_id);
    }
    case EventType.UPDATE_USER_GOODS: {
      return getUserGoods(user_id);
    }
    case EventType.UPDATE_USER_SHOP: {
      return getUserShop(user_id);
    }
    case EventType.CHANGE_USER_NAME: {
      return changeName(user_id, data);
    }
    case EventType.ARRAYING_ROLE_UP: {
      return roleUp(user_id, data);
    }
    case EventType.ARRAYING_ROLE_DOWN: {
      return roleDown(user_id, data);
    }
    case EventType.ARRAYING_ROLE_CHANGE: {
      return roleChange(user_id, data);
    }
    case EventType.ARRAYING_ROLE_EQUIP_CHANGE: {
      return roleEquipChange(user_id, data);
    }
    case EventType.GOODS_SELL: {
      return goodsSell(user_id, data);
    }
    case EventType.RECRUIT_ROLE: {
      return recruitRole(user_id, data);
    }
    case EventType.ROLE_UPGRADE: {
      return upgradeRole(user_id, data);
    }
    case EventType.VIP_CAN_GET: {
      return vipCanGet(user_id);
    }
    case EventType.VIP_REWARD: {
      return vipReward(user_id, data);
    }
    case EventType.SHOP_BUY: {
      return shopBuy(user_id, data);
    }
    case EventType.BOSS_BATTLE: {
      return bossBattle(user_id, data);
    }
  }
};
